<?php 
	include '../../function.php';

	var_dump($_FILES);
	if (empty($_FILES)) {
		echo "上传文件失败";
		exit();
	}
	$upload = current($_FILES);
	foreach ($upload['error'] as $k => $v) {
		if ($v[$k]>0) {
			echo "文件上传失败错误代码".$v[$k]."<br>";
			exit();
		}
	}
	$allowType = ['jpg', 'png', 'gif', 'txt', 'php' , 'html', 'wps' , 'pdf'];
	foreach ($upload['name'] as $k => $v) {
		$filesName[$k] = $v;
		$filesType[$k] = explode('.', $v);
		$type[$k] = end($filesType[$k]);
		if (in_array($type, $allowType)) {
			echo "上传文件失败,类型错误,错误类型位".$type[$k];
			exit();
		}
	}
	foreach ($upload['size'] as $k => $v) {
		$filesSize[$k] = $v;
		if ($filesSize[$k]>10000000) {
			echo "文件太大,无法上传";
		}
		// $filesSize[$k] = CF($filesSize[$k]);
	}
	is_dir('./tmpe')||mkdir('./tmpe');
	foreach ($upload['tmp_name'] as $k => $v) {
		$name =uniqid();
		$filesType = explode('.', $upload['name'][$k]);
		$type = end($filesType);
		if (move_uploaded_file($v, './tmpe/'.$name.'.'.$type)){
			echo "上传成功".$filesName[$k];
			header('location:./xxx.php');
		}else{
			echo "上传文件失败";
		}
	}
  	

	// if ($upload['error']>0) {
	// 	echo "文件上传失败错误代码".$upload['error'];
	// 	exit();
	// }
	// $allowType = ['jpg', 'png', 'gif', 'txt', 'php' , 'html', 'wps' , 'pdf'];
	// $filesType = explode('.', $upload['name']);
	// $type = end($filesType);
	// if (!in_array($type, $allowType)) {
	// 	echo "上传文件失败,类型错误,错误类型位".$type;
	// }else{
	// 	is_dir('./tmpe')||mkdir('./tmpe');
	// 	$name =uniqid();
	// 	if (move_uploaded_file($upload['tmp_name'], './tmpe/'.$name.$upload['name'])) {
	// 		echo '上传文件成功';
	// 	}else{
	// 		echo "上传文件失败";
	// 	}
	// }













 ?>